package com.mycoupon.mycouponframework.exception;

import com.mycoupon.mycouponframework.errorcode.IErrorCode;

/**
 * @projectName: MyCoupon
 * @package: com.mycoupon.mycouponframework.exception
 * @className: AbstractException
 * @author: thinkBook
 * @description: TODO
 * @date: 2025/4/4 22:06
 * @version: 1.0
 */
public class AbstractException extends RuntimeException{

    public final String errorCode;
    public final String errorMessage;

    /**
     * @description 异常有自己的错误码和错误信息，继承super，把它放进栈中
     * @param message:
     * @param throwable:
     * @param errorCode:
     * @return null
     * @author caoyumeng
     * @date 2025/4/4 22:09
     */
    public AbstractException(String message, Throwable throwable, IErrorCode errorCode) {
        /**
         * @description  java子类对象构造初始化一定要调用父类的构造方法，若没有显示调用，则隐式调用父类的无参构造
         * 子类继承父类的私有属性，但不能访问，必须通过父类的get/set进行访问
         */
        super(message, throwable);
        this.errorCode = errorCode.code();
        this.errorMessage = errorCode.message();
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}
